home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Online / Apache / include / apache / httpd.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-06  |  43.8 KB  |  1,212 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  *
  54.  * Portions of this software are based upon public domain software
  55.  * originally written at the National Center for Supercomputing Applications,
  56.  * University of Illinois, Urbana-Champaign.
  57.  */
  58.  
  59. #ifndef APACHE_HTTPD_H
  60. #define APACHE_HTTPD_H
  61.  
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif
  65.  
  66. /*
  67.  * httpd.h: header for simple (ha! not anymore) http daemon
  68.  */
  69.  
  70. /* Headers in which EVERYONE has an interest... */
  71.  
  72. #include "ap_config.h"
  73. #include "ap_alloc.h"
  74. #include "buff.h"
  75. #include "ap.h"
  76.  
  77. /* ----------------------------- config dir ------------------------------ */
  78.  
  79. /* Define this to be the default server home dir. Most things later in this
  80.  * file with a relative pathname will have this added.
  81.  */
  82. #ifndef HTTPD_ROOT
  83. #ifdef OS2
  84. /* Set default for OS/2 file system */
  85. #define HTTPD_ROOT "/os2httpd"
  86. #elif defined(WIN32)
  87. /* Set default for Windows file system */
  88. #define HTTPD_ROOT "/apache"
  89. #elif defined(BEOS) || defined(BONE)
  90. #define HTTPD_ROOT "/boot/home/apache"
  91. #elif defined(NETWARE)
  92. #define HTTPD_ROOT "sys:/apache"
  93. #else
  94. #define HTTPD_ROOT "/usr/local/apache"
  95. #endif
  96. #endif /* HTTPD_ROOT */
  97.  
  98. /* Default location of documents.  Can be overridden by the DocumentRoot
  99.  * directive.
  100.  */
  101. #ifndef DOCUMENT_LOCATION
  102. #ifdef OS2
  103. /* Set default for OS/2 file system */
  104. #define DOCUMENT_LOCATION  HTTPD_ROOT "/docs"
  105. #else
  106. #define DOCUMENT_LOCATION  HTTPD_ROOT "/htdocs"
  107. #endif
  108. #endif /* DOCUMENT_LOCATION */
  109.  
  110. /* Max. number of dynamically loaded modules */
  111. #ifndef DYNAMIC_MODULE_LIMIT
  112. #define DYNAMIC_MODULE_LIMIT 64
  113. #endif
  114.  
  115. /* Default administrator's address */
  116. #define DEFAULT_ADMIN "[no address given]"
  117.  
  118. /* The target name of the installed Apache */
  119. #ifndef TARGET
  120. #define TARGET "httpd"
  121. #endif
  122.  
  123. /* 
  124.  * --------- You shouldn't have to edit anything below this line ----------
  125.  *
  126.  * Any modifications to any defaults not defined above should be done in the 
  127.  * respective config. file. 
  128.  *
  129.  */
  130.  
  131.  
  132. /* -- Internal representation for a HTTP protocol number, e.g., HTTP/1.1 -- */
  133.  
  134. #define HTTP_VERSION(major,minor) (1000*(major)+(minor))
  135. #define HTTP_VERSION_MAJOR(number) ((number)/1000)
  136. #define HTTP_VERSION_MINOR(number) ((number)%1000)
  137.  
  138.  
  139. /* -------------- Port number for server running standalone --------------- */
  140.  
  141. #define DEFAULT_HTTP_PORT    80
  142. #define DEFAULT_HTTPS_PORT    443
  143. #define ap_is_default_port(port,r)    ((port) == ap_default_port(r))
  144. #define ap_http_method(r)    "http"
  145. #define ap_default_port(r)    DEFAULT_HTTP_PORT
  146.  
  147. /* --------- Default user name and group name running standalone ---------- */
  148. /* --- These may be specified as numbers by placing a # before a number --- */
  149.  
  150. #ifndef DEFAULT_USER
  151. #define DEFAULT_USER "#-1"
  152. #endif
  153. #ifndef DEFAULT_GROUP
  154. #define DEFAULT_GROUP "#-1"
  155. #endif
  156.  
  157. /* The name of the log files */
  158. #ifndef DEFAULT_XFERLOG
  159. #if defined(OS2) || defined(WIN32)
  160. #define DEFAULT_XFERLOG "logs/access.log"
  161. #else
  162. #define DEFAULT_XFERLOG "logs/access_log"
  163. #endif
  164. #endif /* DEFAULT_XFERLOG */
  165.  
  166. #ifndef DEFAULT_ERRORLOG
  167. #if defined(OS2) || defined(WIN32)
  168. #define DEFAULT_ERRORLOG "logs/error.log"
  169. #else
  170. #define DEFAULT_ERRORLOG "logs/error_log"
  171. #endif
  172. #endif /* DEFAULT_ERRORLOG */
  173.  
  174. #ifndef DEFAULT_PIDLOG
  175. #define DEFAULT_PIDLOG "logs/httpd.pid"
  176. #endif
  177. #ifndef DEFAULT_SCOREBOARD
  178. #define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
  179. #endif
  180. #ifndef DEFAULT_LOCKFILE
  181. #define DEFAULT_LOCKFILE "logs/accept.lock"
  182. #endif
  183.  
  184. /* Define this to be what your HTML directory content files are called */
  185. #ifndef DEFAULT_INDEX
  186. #define DEFAULT_INDEX "index.html"
  187. #endif
  188.  
  189. /* Define this to 1 if you want fancy indexing, 0 otherwise */
  190. #ifndef DEFAULT_INDEXING
  191. #define DEFAULT_INDEXING 0
  192. #endif
  193.  
  194. /* Define this to be what type you'd like returned for files with unknown */
  195. /* suffixes.  MUST be all lower case. */
  196. #ifndef DEFAULT_CONTENT_TYPE
  197. #define DEFAULT_CONTENT_TYPE "text/plain"
  198. #endif
  199.  
  200. /* Define this to be what your per-directory security files are called */
  201. #ifndef DEFAULT_ACCESS_FNAME
  202. #ifdef OS2
  203. /* Set default for OS/2 file system */
  204. #define DEFAULT_ACCESS_FNAME "htaccess"
  205. #else
  206. #define DEFAULT_ACCESS_FNAME ".htaccess"
  207. #endif
  208. #endif /* DEFAULT_ACCESS_FNAME */
  209.  
  210. /* The name of the server config file */
  211. #ifndef SERVER_CONFIG_FILE
  212. #define SERVER_CONFIG_FILE "conf/httpd.conf"
  213. #endif
  214.  
  215. /* The name of the document config file */
  216. #ifndef RESOURCE_CONFIG_FILE
  217. #define RESOURCE_CONFIG_FILE "conf/srm.conf"
  218. #endif
  219.  
  220. /* The name of the MIME types file */
  221. #ifndef TYPES_CONFIG_FILE
  222. #define TYPES_CONFIG_FILE "conf/mime.types"
  223. #endif
  224.  
  225. /* The name of the access file */
  226. #ifndef ACCESS_CONFIG_FILE
  227. #define ACCESS_CONFIG_FILE "conf/access.conf"
  228. #endif
  229.  
  230. /* Whether we should enable rfc1413 identity checking */
  231. #ifndef DEFAULT_RFC1413
  232. #define DEFAULT_RFC1413 0
  233. #endif
  234. /* The default directory in user's home dir */
  235. #ifndef DEFAULT_USER_DIR
  236. #define DEFAULT_USER_DIR "public_html"
  237. #endif
  238.  
  239. /* The default path for CGI scripts if none is currently set */
  240. #ifndef DEFAULT_PATH
  241. #define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin"
  242. #endif
  243.  
  244. /* The path to the shell interpreter, for parsed docs */
  245. #ifndef SHELL_PATH
  246. #if defined(OS2) || defined(WIN32)
  247. /* Set default for OS/2 and Windows file system */
  248. #define SHELL_PATH "CMD.EXE"
  249. #else
  250. #define SHELL_PATH "/bin/sh"
  251. #endif
  252. #endif /* SHELL_PATH */
  253.  
  254. /* The path to the suExec wrapper, can be overridden in Configuration */
  255. #ifndef SUEXEC_BIN
  256. #define SUEXEC_BIN  HTTPD_ROOT "/bin/suexec"
  257. #endif
  258.  
  259. /* The default string lengths */
  260. #define MAX_STRING_LEN HUGE_STRING_LEN
  261. #define HUGE_STRING_LEN 8192
  262.  
  263. /* The timeout for waiting for messages */
  264. #ifndef DEFAULT_TIMEOUT
  265. #define DEFAULT_TIMEOUT 300
  266. #endif
  267.  
  268. /* The timeout for waiting for keepalive timeout until next request */
  269. #ifndef DEFAULT_KEEPALIVE_TIMEOUT
  270. #define DEFAULT_KEEPALIVE_TIMEOUT 15
  271. #endif
  272.  
  273. /* The number of requests to entertain per connection */
  274. #ifndef DEFAULT_KEEPALIVE
  275. #define DEFAULT_KEEPALIVE 100
  276. #endif
  277.  
  278. /* The size of the server's internal read-write buffers */
  279. #define IOBUFSIZE 8192
  280.  
  281. /* Number of servers to spawn off by default --- also, if fewer than
  282.  * this free when the caretaker checks, it will spawn more.
  283.  */
  284. #ifndef DEFAULT_START_DAEMON
  285. #define DEFAULT_START_DAEMON 5
  286. #endif
  287.  
  288. /* Maximum number of *free* server processes --- more than this, and
  289.  * they will die off.
  290.  */
  291.  
  292. #ifndef DEFAULT_MAX_FREE_DAEMON
  293. #define DEFAULT_MAX_FREE_DAEMON 10
  294. #endif
  295.  
  296. /* Minimum --- fewer than this, and more will be created */
  297.  
  298. #ifndef DEFAULT_MIN_FREE_DAEMON
  299. #define DEFAULT_MIN_FREE_DAEMON 5
  300. #endif
  301.  
  302. /* Limit on the total --- clients will be locked out if more servers than
  303.  * this are needed.  It is intended solely to keep the server from crashing
  304.  * when things get out of hand.
  305.  *
  306.  * We keep a hard maximum number of servers, for two reasons --- first off,
  307.  * in case something goes seriously wrong, we want to stop the fork bomb
  308.  * short of actually crashing the machine we're running on by filling some
  309.  * kernel table.  Secondly, it keeps the size of the scoreboard file small
  310.  * enough that we can read the whole thing without worrying too much about
  311.  * the overhead.
  312.  */
  313. #ifndef HARD_SERVER_LIMIT
  314. #ifdef WIN32
  315. #define HARD_SERVER_LIMIT 1024
  316. #else
  317. #define HARD_SERVER_LIMIT 256
  318. #endif
  319. #endif
  320.  
  321. /*
  322.  * Special Apache error codes. These are basically used
  323.  *  in http_main.c so we can keep track of various errors.
  324.  *
  325.  *   APEXIT_OK:
  326.  *     A normal exit
  327.  *   APEXIT_INIT:
  328.  *     A fatal error arising during the server's init sequence
  329.  *   APEXIT_CHILDINIT:
  330.  *     The child died during it's init sequence
  331.  *   APEXIT_CHILDFATAL:
  332.  *     A fatal error, resulting in the whole server aborting.
  333.  *     If a child exits with this error, the parent process
  334.  *     considers this a server-wide fatal error and aborts.
  335.  *                 
  336.  */
  337. #define APEXIT_OK        0x0
  338. #define APEXIT_INIT        0x2
  339. #define APEXIT_CHILDINIT    0x3
  340. #define APEXIT_CHILDFATAL    0xf
  341.  
  342. /*
  343.  * (Unix, OS/2 only)
  344.  * Interval, in microseconds, between scoreboard maintenance.  During
  345.  * each scoreboard maintenance cycle the parent decides if it needs to
  346.  * spawn a new child (to meet MinSpareServers requirements), or kill off
  347.  * a child (to meet MaxSpareServers requirements).  It will only spawn or
  348.  * kill one child per cycle.  Setting this too low will chew cpu.  The
  349.  * default is probably sufficient for everyone.  But some people may want
  350.  * to raise this on servers which aren't dedicated to httpd and where they
  351.  * don't like the httpd waking up each second to see what's going on.
  352.  */
  353. #ifndef SCOREBOARD_MAINTENANCE_INTERVAL
  354. #define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
  355. #endif
  356.  
  357. /* Number of requests to try to handle in a single process.  If <= 0,
  358.  * the children don't die off.  That's the default here, since I'm still
  359.  * interested in finding and stanching leaks.
  360.  */
  361.  
  362. #ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
  363. #define DEFAULT_MAX_REQUESTS_PER_CHILD 0
  364. #endif
  365.  
  366. #ifndef DEFAULT_THREADS_PER_CHILD
  367. #define DEFAULT_THREADS_PER_CHILD 50
  368. #endif
  369. #ifndef DEFAULT_EXCESS_REQUESTS_PER_CHILD
  370. #define DEFAULT_EXCESS_REQUESTS_PER_CHILD 0
  371. #endif
  372.  
  373. /* The maximum length of the queue of pending connections, as defined
  374.  * by listen(2).  Under some systems, it should be increased if you
  375.  * are experiencing a heavy TCP SYN flood attack.
  376.  *
  377.  * It defaults to 511 instead of 512 because some systems store it 
  378.  * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is 
  379.  * 255 when truncated.
  380.  */
  381.  
  382. #ifndef DEFAULT_LISTENBACKLOG
  383. #define DEFAULT_LISTENBACKLOG 511
  384. #endif
  385.  
  386. /* Limits on the size of various request items.  These limits primarily
  387.  * exist to prevent simple denial-of-service attacks on a server based
  388.  * on misuse of the protocol.  The recommended values will depend on the
  389.  * nature of the server resources -- CGI scripts and database backends
  390.  * might require large values, but most servers could get by with much
  391.  * smaller limits than we use below.  The request message body size can
  392.  * be limited by the per-dir config directive LimitRequestBody.
  393.  *
  394.  * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE
  395.  * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190.
  396.  * These two limits can be lowered (but not raised) by the server config
  397.  * directives LimitRequestLine and LimitRequestFieldsize, respectively.
  398.  *
  399.  * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by
  400.  * the server config directive LimitRequestFields.
  401.  */
  402. #ifndef DEFAULT_LIMIT_REQUEST_LINE
  403. #define DEFAULT_LIMIT_REQUEST_LINE 8190
  404. #endif /* default limit on bytes in Request-Line (Method+URI+HTTP-version) */
  405. #ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE
  406. #define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190
  407. #endif /* default limit on bytes in any one header field  */
  408. #ifndef DEFAULT_LIMIT_REQUEST_FIELDS
  409. #define DEFAULT_LIMIT_REQUEST_FIELDS 100
  410. #endif /* default limit on number of request header fields */
  411.  
  412. /*
  413.  * The default default character set name to add if AddDefaultCharset is 
  414.  * enabled.  Overridden with AddDefaultCharsetName.
  415.  */
  416. #define DEFAULT_ADD_DEFAULT_CHARSET_NAME "iso-8859-1"
  417.  
  418. /*
  419.  * The below defines the base string of the Server: header. Additional
  420.  * tokens can be added via the ap_add_version_component() API call.
  421.  *
  422.  * The tokens are listed in order of their significance for identifying the
  423.  * application.
  424.  *
  425.  * "Product tokens should be short and to the point -- use of them for 
  426.  * advertizing or other non-essential information is explicitly forbidden."
  427.  *
  428.  * Example: "Apache/1.1.0 MrWidget/0.1-alpha" 
  429.  */
  430.  
  431. #define SERVER_BASEVENDOR   "Apache Group"
  432. #define SERVER_BASEPRODUCT  "Apache"
  433. #define SERVER_BASEREVISION "1.3.19"
  434. #define SERVER_BASEVERSION  SERVER_BASEPRODUCT "/" SERVER_BASEREVISION
  435.  
  436. #define SERVER_PRODUCT  SERVER_BASEPRODUCT
  437. #define SERVER_REVISION SERVER_BASEREVISION
  438. #define SERVER_VERSION  SERVER_PRODUCT "/" SERVER_REVISION
  439. enum server_token_type {
  440.     SrvTk_MIN,        /* eg: Apache/1.3.0 */
  441.     SrvTk_OS,        /* eg: Apache/1.3.0 (UNIX) */
  442.     SrvTk_FULL,        /* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */
  443.     SrvTk_PRODUCT_ONLY    /* eg: Apache */
  444. };
  445.  
  446. API_EXPORT(const char *) ap_get_server_version(void);
  447. API_EXPORT(void) ap_add_version_component(const char *component);
  448. API_EXPORT(const char *) ap_get_server_built(void);
  449.  
  450. /* Numeric release version identifier: MMNNFFRBB: major minor fix final beta
  451.  * Always increases along the same track as the source branch.
  452.  * For example, Apache 1.4.2 would be '10402100', 2.5b7 would be '20500007'.
  453.  */
  454. #define APACHE_RELEASE 10319100
  455.  
  456. #define SERVER_PROTOCOL "HTTP/1.1"
  457. #ifndef SERVER_SUPPORT
  458. #define SERVER_SUPPORT "http://www.apache.org/"
  459. #endif
  460.  
  461. #define DECLINED -1        /* Module declines to handle */
  462. #define DONE -2            /* Module has served the response completely 
  463.                  *  - it's safe to die() with no more output
  464.                  */
  465. #define OK 0            /* Module has handled this stage. */
  466.  
  467.  
  468. /* ----------------------- HTTP Status Codes  ------------------------- */
  469.  
  470. /* The size of the static array in http_protocol.c for storing
  471.  * all of the potential response status-lines (a sparse table).
  472.  * A future version should dynamically generate the table at startup.
  473.  */
  474. #define RESPONSE_CODES 55
  475.  
  476. #define HTTP_CONTINUE                      100
  477. #define HTTP_SWITCHING_PROTOCOLS           101
  478. #define HTTP_PROCESSING                    102
  479. #define HTTP_OK                            200
  480. #define HTTP_CREATED                       201
  481. #define HTTP_ACCEPTED                      202
  482. #define HTTP_NON_AUTHORITATIVE             203
  483. #define HTTP_NO_CONTENT                    204
  484. #define HTTP_RESET_CONTENT                 205
  485. #define HTTP_PARTIAL_CONTENT               206
  486. #define HTTP_MULTI_STATUS                  207
  487. #define HTTP_MULTIPLE_CHOICES              300
  488. #define HTTP_MOVED_PERMANENTLY             301
  489. #define HTTP_MOVED_TEMPORARILY             302
  490. #define HTTP_SEE_OTHER                     303
  491. #define HTTP_NOT_MODIFIED                  304
  492. #define HTTP_USE_PROXY                     305
  493. #define HTTP_TEMPORARY_REDIRECT            307
  494. #define HTTP_BAD_REQUEST                   400
  495. #define HTTP_UNAUTHORIZED                  401
  496. #define HTTP_PAYMENT_REQUIRED              402
  497. #define HTTP_FORBIDDEN                     403
  498. #define HTTP_NOT_FOUND                     404
  499. #define HTTP_METHOD_NOT_ALLOWED            405
  500. #define HTTP_NOT_ACCEPTABLE                406
  501. #define HTTP_PROXY_AUTHENTICATION_REQUIRED 407
  502. #define HTTP_REQUEST_TIME_OUT              408
  503. #define HTTP_CONFLICT                      409
  504. #define HTTP_GONE                          410
  505. #define HTTP_LENGTH_REQUIRED               411
  506. #define HTTP_PRECONDITION_FAILED           412
  507. #define HTTP_REQUEST_ENTITY_TOO_LARGE      413
  508. #define HTTP_REQUEST_URI_TOO_LARGE         414
  509. #define HTTP_UNSUPPORTED_MEDIA_TYPE        415
  510. #define HTTP_RANGE_NOT_SATISFIABLE         416
  511. #define HTTP_EXPECTATION_FAILED            417
  512. #define HTTP_UNPROCESSABLE_ENTITY          422
  513. #define HTTP_LOCKED                        423
  514. #define HTTP_FAILED_DEPENDENCY             424
  515. #define HTTP_INTERNAL_SERVER_ERROR         500
  516. #define HTTP_NOT_IMPLEMENTED               501
  517. #define HTTP_BAD_GATEWAY                   502
  518. #define HTTP_SERVICE_UNAVAILABLE           503
  519. #define HTTP_GATEWAY_TIME_OUT              504
  520. #define HTTP_VERSION_NOT_SUPPORTED         505
  521. #define HTTP_VARIANT_ALSO_VARIES           506
  522. #define HTTP_INSUFFICIENT_STORAGE          507
  523. #define HTTP_NOT_EXTENDED                  510
  524.  
  525. #define DOCUMENT_FOLLOWS    HTTP_OK
  526. #define PARTIAL_CONTENT     HTTP_PARTIAL_CONTENT
  527. #define MULTIPLE_CHOICES    HTTP_MULTIPLE_CHOICES
  528. #define MOVED               HTTP_MOVED_PERMANENTLY
  529. #define REDIRECT            HTTP_MOVED_TEMPORARILY
  530. #define USE_LOCAL_COPY      HTTP_NOT_MODIFIED
  531. #define BAD_REQUEST         HTTP_BAD_REQUEST
  532. #define AUTH_REQUIRED       HTTP_UNAUTHORIZED
  533. #define FORBIDDEN           HTTP_FORBIDDEN
  534. #define NOT_FOUND           HTTP_NOT_FOUND
  535. #define METHOD_NOT_ALLOWED  HTTP_METHOD_NOT_ALLOWED
  536. #define NOT_ACCEPTABLE      HTTP_NOT_ACCEPTABLE
  537. #define LENGTH_REQUIRED     HTTP_LENGTH_REQUIRED
  538. #define PRECONDITION_FAILED HTTP_PRECONDITION_FAILED
  539. #define SERVER_ERROR        HTTP_INTERNAL_SERVER_ERROR
  540. #define NOT_IMPLEMENTED     HTTP_NOT_IMPLEMENTED
  541. #define BAD_GATEWAY         HTTP_BAD_GATEWAY
  542. #define VARIANT_ALSO_VARIES HTTP_VARIANT_ALSO_VARIES
  543.  
  544. #define ap_is_HTTP_INFO(x)         (((x) >= 100)&&((x) < 200))
  545. #define ap_is_HTTP_SUCCESS(x)      (((x) >= 200)&&((x) < 300))
  546. #define ap_is_HTTP_REDIRECT(x)     (((x) >= 300)&&((x) < 400))
  547. #define ap_is_HTTP_ERROR(x)        (((x) >= 400)&&((x) < 600))
  548. #define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
  549. #define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
  550.  
  551. #define ap_status_drops_connection(x) \
  552.                                    (((x) == HTTP_BAD_REQUEST)           || \
  553.                                     ((x) == HTTP_REQUEST_TIME_OUT)      || \
  554.                                     ((x) == HTTP_LENGTH_REQUIRED)       || \
  555.                                     ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
  556.                                     ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
  557.                                     ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
  558.                                     ((x) == HTTP_SERVICE_UNAVAILABLE) || \
  559.                     ((x) == HTTP_NOT_IMPLEMENTED))
  560.  
  561. /* Methods recognized (but not necessarily handled) by the server.
  562.  * These constants are used in bit shifting masks of size int, so it is
  563.  * unsafe to have more methods than bits in an int.  HEAD == M_GET.
  564.  */
  565. #define M_GET        0
  566. #define M_PUT        1
  567. #define M_POST       2
  568. #define M_DELETE     3
  569. #define M_CONNECT    4
  570. #define M_OPTIONS    5
  571. #define M_TRACE      6
  572. #define M_PATCH      7
  573. #define M_PROPFIND   8
  574. #define M_PROPPATCH  9
  575. #define M_MKCOL     10
  576. #define M_COPY      11
  577. #define M_MOVE      12
  578. #define M_LOCK      13
  579. #define M_UNLOCK    14
  580. #define M_INVALID   15
  581.  
  582. #define METHODS     16
  583.  
  584. #define CGI_MAGIC_TYPE "application/x-httpd-cgi"
  585. #define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html"
  586. #define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3"
  587. #ifdef CHARSET_EBCDIC
  588. #define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-" /* Text files whose content-type starts with this are passed thru unconverted */
  589. #endif /*CHARSET_EBCDIC*/
  590. #define MAP_FILE_MAGIC_TYPE "application/x-type-map"
  591. #define ASIS_MAGIC_TYPE "httpd/send-as-is"
  592. #define DIR_MAGIC_TYPE "httpd/unix-directory"
  593. #define STATUS_MAGIC_TYPE "application/x-httpd-status"
  594.  
  595. /*
  596.  * Define the HTML doctype strings centrally.
  597.  */
  598. #define DOCTYPE_HTML_2_0  "<!DOCTYPE HTML PUBLIC \"-//IETF//" \
  599.                           "DTD HTML 2.0//EN\">\n"
  600. #define DOCTYPE_HTML_3_2  "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
  601.                           "DTD HTML 3.2 Final//EN\">\n"
  602. #define DOCTYPE_HTML_4_0S "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
  603.                           "DTD HTML 4.0//EN\"\n" \
  604.                           "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
  605. #define DOCTYPE_HTML_4_0T "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
  606.                           "DTD HTML 4.0 Transitional//EN\"\n" \
  607.                           "\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n"
  608. #define DOCTYPE_HTML_4_0F "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
  609.                           "DTD HTML 4.0 Frameset//EN\"\n" \
  610.                           "\"http://www.w3.org/TR/REC-html40/frameset.dtd\">\n"
  611.  
  612. /* Just in case your linefeed isn't the one the other end is expecting. */
  613. #ifndef CHARSET_EBCDIC
  614. #define LF 10
  615. #define CR 13
  616. #define CRLF "\015\012"
  617. #define OS_ASC(c) (c)
  618. #else /* CHARSET_EBCDIC */
  619. #include "ebcdic.h"
  620. /* OSD_POSIX uses the EBCDIC charset. The transition ASCII->EBCDIC is done in
  621.  * the buff package (bread/bputs/bwrite), so everywhere else, we use
  622.  * "native EBCDIC" CR and NL characters. These are therefore defined as
  623.  * '\r' and '\n'.
  624.  * NB: this is not the whole truth - sometimes \015 and \012 are contained
  625.  * in literal (EBCDIC!) strings, so these are not converted but passed.
  626.  */
  627. #define CR '\r'
  628. #define LF '\n'
  629. #define CRLF "\r\n"
  630. #define OS_ASC(c) (os_toascii[c])
  631. #endif /* CHARSET_EBCDIC */
  632.  
  633. /* Possible values for request_rec.read_body (set by handling module):
  634.  *    REQUEST_NO_BODY          Send 413 error if message has any body
  635.  *    REQUEST_CHUNKED_ERROR    Send 411 error if body without Content-Length
  636.  *    REQUEST_CHUNKED_DECHUNK  If chunked, remove the chunks for me.
  637.  *    REQUEST_CHUNKED_PASS     Pass the chunks to me without removal.
  638.  */
  639. #define REQUEST_NO_BODY          0
  640. #define REQUEST_CHUNKED_ERROR    1
  641. #define REQUEST_CHUNKED_DECHUNK  2
  642. #define REQUEST_CHUNKED_PASS     3
  643.  
  644. /* Things which may vary per file-lookup WITHIN a request ---
  645.  * e.g., state of MIME config.  Basically, the name of an object, info
  646.  * about the object, and any other info we may ahve which may need to
  647.  * change as we go poking around looking for it (e.g., overridden by
  648.  * .htaccess files).
  649.  *
  650.  * Note how the default state of almost all these things is properly
  651.  * zero, so that allocating it with pcalloc does the right thing without
  652.  * a whole lot of hairy initialization... so long as we are willing to
  653.  * make the (fairly) portable assumption that the bit pattern of a NULL
  654.  * pointer is, in fact, zero.
  655.  */
  656.  
  657. /* This represents the result of calling htaccess; these are cached for
  658.  * each request.
  659.  */
  660. struct htaccess_result {
  661.     char *dir;            /* the directory to which this applies */
  662.     int override;        /* the overrides allowed for the .htaccess file */
  663.     void *htaccess;        /* the configuration directives */
  664. /* the next one, or NULL if no more; N.B. never change this */
  665.     const struct htaccess_result *next;
  666. };
  667.  
  668. typedef struct conn_rec conn_rec;
  669. typedef struct server_rec server_rec;
  670. typedef struct request_rec request_rec;
  671. typedef struct listen_rec listen_rec;
  672.  
  673. #include "util_uri.h"
  674.  
  675. enum proxyreqtype {
  676.     NOT_PROXY=0,
  677.     STD_PROXY,
  678.     PROXY_PASS
  679. };
  680.  
  681. struct request_rec {
  682.  
  683.     ap_pool *pool;
  684.     conn_rec *connection;
  685.     server_rec *server;
  686.  
  687.     request_rec *next;        /* If we wind up getting redirected,
  688.                  * pointer to the request we redirected to.
  689.                  */
  690.     request_rec *prev;        /* If this is an internal redirect,
  691.                  * pointer to where we redirected *from*.
  692.                  */
  693.  
  694.     request_rec *main;        /* If this is a sub_request (see request.h) 
  695.                  * pointer back to the main request.
  696.                  */
  697.  
  698.     /* Info about the request itself... we begin with stuff that only
  699.      * protocol.c should ever touch...
  700.      */
  701.  
  702.     char *the_request;        /* First line of request, so we can log it */
  703.     int assbackwards;        /* HTTP/0.9, "simple" request */
  704.     enum proxyreqtype proxyreq;/* A proxy request (calculated during
  705.                  * post_read_request or translate_name) */
  706.     int header_only;        /* HEAD request, as opposed to GET */
  707.     char *protocol;        /* Protocol, as given to us, or HTTP/0.9 */
  708.     int proto_num;        /* Number version of protocol; 1.1 = 1001 */
  709.     const char *hostname;    /* Host, as set by full URI or Host: */
  710.  
  711.     time_t request_time;    /* When the request started */
  712.  
  713.     const char *status_line;    /* Status line, if set by script */
  714.     int status;            /* In any case */
  715.  
  716.     /* Request method, two ways; also, protocol, etc..  Outside of protocol.c,
  717.      * look, but don't touch.
  718.      */
  719.  
  720.     const char *method;        /* GET, HEAD, POST, etc. */
  721.     int method_number;        /* M_GET, M_POST, etc. */
  722.  
  723.     /*
  724.     allowed is a bitvector of the allowed methods.
  725.  
  726.     A handler must ensure that the request method is one that
  727.     it is capable of handling.  Generally modules should DECLINE
  728.     any request methods they do not handle.  Prior to aborting the
  729.     handler like this the handler should set r->allowed to the list
  730.     of methods that it is willing to handle.  This bitvector is used
  731.     to construct the "Allow:" header required for OPTIONS requests,
  732.     and METHOD_NOT_ALLOWED and NOT_IMPLEMENTED status codes.
  733.  
  734.     Since the default_handler deals with OPTIONS, all modules can
  735.     usually decline to deal with OPTIONS.  TRACE is always allowed,
  736.     modules don't need to set it explicitly.
  737.  
  738.     Since the default_handler will always handle a GET, a
  739.     module which does *not* implement GET should probably return
  740.     METHOD_NOT_ALLOWED.  Unfortunately this means that a Script GET
  741.     handler can't be installed by mod_actions.
  742.     */
  743.     int allowed;        /* Allowed methods - for 405, OPTIONS, etc */
  744.  
  745.     int sent_bodyct;        /* byte count in stream is for body */
  746.     long bytes_sent;        /* body byte count, for easy access */
  747.     time_t mtime;        /* Time the resource was last modified */
  748.  
  749.     /* HTTP/1.1 connection-level features */
  750.  
  751.     int chunked;        /* sending chunked transfer-coding */
  752.     int byterange;        /* number of byte ranges */
  753.     char *boundary;        /* multipart/byteranges boundary */
  754.     const char *range;        /* The Range: header */
  755.     long clength;        /* The "real" content length */
  756.  
  757.     long remaining;        /* bytes left to read */
  758.     long read_length;        /* bytes that have been read */
  759.     int read_body;        /* how the request body should be read */
  760.     int read_chunked;        /* reading chunked transfer-coding */
  761.     unsigned expecting_100;    /* is client waiting for a 100 response? */
  762.  
  763.     /* MIME header environments, in and out.  Also, an array containing
  764.      * environment variables to be passed to subprocesses, so people can
  765.      * write modules to add to that environment.
  766.      *
  767.      * The difference between headers_out and err_headers_out is that the
  768.      * latter are printed even on error, and persist across internal redirects
  769.      * (so the headers printed for ErrorDocument handlers will have them).
  770.      *
  771.      * The 'notes' table is for notes from one module to another, with no
  772.      * other set purpose in mind...
  773.      */
  774.  
  775.     table *headers_in;
  776.     table *headers_out;
  777.     table *err_headers_out;
  778.     table *subprocess_env;
  779.     table *notes;
  780.  
  781.     /* content_type, handler, content_encoding, content_language, and all
  782.      * content_languages MUST be lowercased strings.  They may be pointers
  783.      * to static strings; they should not be modified in place.
  784.      */
  785.     const char *content_type;    /* Break these out --- we dispatch on 'em */
  786.     const char *handler;    /* What we *really* dispatch on           */
  787.  
  788.     const char *content_encoding;
  789.     const char *content_language;    /* for back-compat. only -- do not use */
  790.     array_header *content_languages;    /* array of (char*) */
  791.  
  792.     char *vlist_validator;      /* variant list validator (if negotiated) */
  793.  
  794.     int no_cache;
  795.     int no_local_copy;
  796.  
  797.     /* What object is being requested (either directly, or via include
  798.      * or content-negotiation mapping).
  799.      */
  800.  
  801.     char *unparsed_uri;        /* the uri without any parsing performed */
  802.     char *uri;            /* the path portion of the URI */
  803.     char *filename;
  804.     char *path_info;
  805.     char *args;            /* QUERY_ARGS, if any */
  806.     struct stat finfo;        /* ST_MODE set to zero if no such file */
  807.     uri_components parsed_uri;    /* components of uri, dismantled */
  808.  
  809.     /* Various other config info which may change with .htaccess files
  810.      * These are config vectors, with one void* pointer for each module
  811.      * (the thing pointed to being the module's business).
  812.      */
  813.  
  814.     void *per_dir_config;    /* Options set in config files, etc. */
  815.     void *request_config;    /* Notes on *this* request */
  816.  
  817. /*
  818.  * a linked list of the configuration directives in the .htaccess files
  819.  * accessed by this request.
  820.  * N.B. always add to the head of the list, _never_ to the end.
  821.  * that way, a sub request's list can (temporarily) point to a parent's list
  822.  */
  823.     const struct htaccess_result *htaccess;
  824.  
  825.     /* On systems with case insensitive file systems (Windows, OS/2, etc.), 
  826.      * r->filename is case canonicalized (folded to either lower or upper 
  827.      * case, depending on the specific system) to accomodate file access
  828.      * checking. case_preserved_filename is the same as r->filename 
  829.      * except case is preserved. There is at least one instance where Apache 
  830.      * needs access to the case preserved filename: Java class files published 
  831.      * with WebDAV need to preserve filename case to make the Java compiler 
  832.      * happy.
  833.      */
  834.     char *case_preserved_filename;
  835.  
  836. /* Things placed at the end of the record to avoid breaking binary
  837.  * compatibility.  It would be nice to remember to reorder the entire
  838.  * record to improve 64bit alignment the next time we need to break
  839.  * binary compatibility for some other reason.
  840.  */
  841. };
  842.  
  843.  
  844. /* Things which are per connection
  845.  */
  846.  
  847. struct conn_rec {
  848.  
  849.     ap_pool *pool;
  850.     server_rec *server;
  851.     server_rec *base_server;    /* Physical vhost this conn come in on */
  852.     void *vhost_lookup_data;    /* used by http_vhost.c */
  853.  
  854.     /* Information about the connection itself */
  855.  
  856.     int child_num;        /* The number of the child handling conn_rec */
  857.     BUFF *client;        /* Connection to the guy */
  858.  
  859.     /* Who is the client? */
  860.  
  861.     struct sockaddr_in local_addr;    /* local address */
  862.     struct sockaddr_in remote_addr;    /* remote address */
  863.     char *remote_ip;        /* Client's IP address */
  864.     char *remote_host;        /* Client's DNS name, if known.
  865.                  * NULL if DNS hasn't been checked,
  866.                  * "" if it has and no address was found.
  867.                  * N.B. Only access this though
  868.                  * get_remote_host() */
  869.     char *remote_logname;    /* Only ever set if doing rfc1413 lookups.
  870.                  * N.B. Only access this through
  871.                  * get_remote_logname() */
  872.     char *user;            /* If an authentication check was made,
  873.                  * this gets set to the user name.  We assume
  874.                  * that there's only one user per connection(!)
  875.                  */
  876.     char *ap_auth_type;        /* Ditto. */
  877.  
  878.     unsigned aborted:1;        /* Are we still talking? */
  879.     signed int keepalive:2;    /* Are we using HTTP Keep-Alive?
  880.                  * -1 fatal error, 0 undecided, 1 yes */
  881.     unsigned keptalive:1;    /* Did we use HTTP Keep-Alive? */
  882.     signed int double_reverse:2;/* have we done double-reverse DNS?
  883.                  * -1 yes/failure, 0 not yet, 1 yes/success */
  884.     int keepalives;        /* How many times have we used it? */
  885.     char *local_ip;        /* server IP address */
  886.     char *local_host;        /* used for ap_get_server_name when
  887.                  * UseCanonicalName is set to DNS
  888.                  * (ignores setting of HostnameLookups) */
  889. };
  890.  
  891. /* Per-vhost config... */
  892.  
  893. /* The address 255.255.255.255, when used as a virtualhost address,
  894.  * will become the "default" server when the ip doesn't match other vhosts.
  895.  */
  896. #define DEFAULT_VHOST_ADDR 0xfffffffful
  897.  
  898. typedef struct server_addr_rec server_addr_rec;
  899. struct server_addr_rec {
  900.     server_addr_rec *next;
  901.     struct in_addr host_addr;    /* The bound address, for this server */
  902.     unsigned short host_port;    /* The bound port, for this server */
  903.     char *virthost;        /* The name given in <VirtualHost> */
  904. };
  905.  
  906. struct server_rec {
  907.  
  908.     server_rec *next;
  909.  
  910.     /* description of where the definition came from */
  911.     const char *defn_name;
  912.     unsigned defn_line_number;
  913.  
  914.     /* Full locations of server config info */
  915.  
  916.     char *srm_confname;
  917.     char *access_confname;
  918.  
  919.     /* Contact information */
  920.  
  921.     char *server_admin;
  922.     char *server_hostname;
  923.     unsigned short port;    /* for redirects, etc. */
  924.  
  925.     /* Log files --- note that transfer log is now in the modules... */
  926.  
  927.     char *error_fname;
  928.     FILE *error_log;
  929.     int loglevel;
  930.  
  931.     /* Module-specific configuration for server, and defaults... */
  932.  
  933.     int is_virtual;        /* true if this is the virtual server */
  934.     void *module_config;    /* Config vector containing pointers to
  935.                  * modules' per-server config structures.
  936.                  */
  937.     void *lookup_defaults;    /* MIME type info, etc., before we start
  938.                  * checking per-directory info.
  939.                  */
  940.     /* Transaction handling */
  941.  
  942.     server_addr_rec *addrs;
  943.     int timeout;        /* Timeout, in seconds, before we give up */
  944.     int keep_alive_timeout;    /* Seconds we'll wait for another request */
  945.     int keep_alive_max;        /* Maximum requests per connection */
  946.     int keep_alive;        /* Use persistent connections? */
  947.     int send_buffer_size;    /* size of TCP send buffer (in bytes) */
  948.  
  949.     char *path;            /* Pathname for ServerPath */
  950.     int pathlen;        /* Length of path */
  951.  
  952.     array_header *names;    /* Normal names for ServerAlias servers */
  953.     array_header *wild_names;    /* Wildcarded names for ServerAlias servers */
  954.  
  955.     uid_t server_uid;        /* effective user id when calling exec wrapper */
  956.     gid_t server_gid;        /* effective group id when calling exec wrapper */
  957.  
  958.     int limit_req_line;      /* limit on size of the HTTP request line    */
  959.     int limit_req_fieldsize; /* limit on size of any request header field */
  960.     int limit_req_fields;    /* limit on number of request header fields  */
  961. };
  962.  
  963. /* These are more like real hosts than virtual hosts */
  964. struct listen_rec {
  965.     listen_rec *next;
  966.     struct sockaddr_in local_addr;    /* local IP address and port */
  967.     int fd;
  968.     int used;            /* Only used during restart */        
  969. /* more stuff here, like which protocol is bound to the port */
  970. };
  971.  
  972. /* Prototypes for utilities... util.c.
  973.  */
  974.  
  975. extern void ap_util_init(void);
  976.  
  977. /* Time */
  978. extern API_VAR_EXPORT const char ap_month_snames[12][4];
  979. extern API_VAR_EXPORT const char ap_day_snames[7][4];
  980.  
  981. API_EXPORT(struct tm *) ap_get_gmtoff(int *tz);
  982. API_EXPORT(char *) ap_get_time(void);
  983. API_EXPORT(char *) ap_field_noparam(pool *p, const char *intype);
  984. API_EXPORT(char *) ap_ht_time(pool *p, time_t t, const char *fmt, int gmt);
  985. API_EXPORT(char *) ap_gm_timestr_822(pool *p, time_t t);
  986.  
  987. /* String handling. The *_nc variants allow you to use non-const char **s as
  988.    arguments (unfortunately C won't automatically convert a char ** to a const
  989.    char **) */
  990.  
  991. API_EXPORT(char *) ap_getword(pool *p, const char **line, char stop);
  992. API_EXPORT(char *) ap_getword_nc(pool *p, char **line, char stop);
  993. API_EXPORT(char *) ap_getword_white(pool *p, const char **line);
  994. API_EXPORT(char *) ap_getword_white_nc(pool *p, char **line);
  995. API_EXPORT(char *) ap_getword_nulls(pool *p, const char **line, char stop);
  996. API_EXPORT(char *) ap_getword_nulls_nc(pool *p, char **line, char stop);
  997. API_EXPORT(char *) ap_getword_conf(pool *p, const char **line);
  998. API_EXPORT(char *) ap_getword_conf_nc(pool *p, char **line);
  999.  
  1000. API_EXPORT(const char *) ap_size_list_item(const char **field, int *len);
  1001. API_EXPORT(char *) ap_get_list_item(pool *p, const char **field);
  1002. API_EXPORT(int) ap_find_list_item(pool *p, const char *line, const char *tok);
  1003.  
  1004. API_EXPORT(char *) ap_get_token(pool *p, const char **accept_line, int accept_white);
  1005. API_EXPORT(int) ap_find_token(pool *p, const char *line, const char *tok);
  1006. API_EXPORT(int) ap_find_last_token(pool *p, const char *line, const char *tok);
  1007.  
  1008. API_EXPORT(int) ap_is_url(const char *u);
  1009. API_EXPORT(int) ap_unescape_url(char *url);
  1010. API_EXPORT(void) ap_no2slash(char *name);
  1011. API_EXPORT(void) ap_getparents(char *name);
  1012. API_EXPORT(char *) ap_escape_path_segment(pool *p, const char *s);
  1013. API_EXPORT(char *) ap_os_escape_path(pool *p, const char *path, int partial);
  1014. #define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1)
  1015. API_EXPORT(char *) ap_escape_html(pool *p, const char *s);
  1016. API_EXPORT(char *) ap_construct_server(pool *p, const char *hostname,
  1017.                     unsigned port, const request_rec *r);
  1018. API_EXPORT(char *) ap_escape_shell_cmd(pool *p, const char *s);
  1019.  
  1020. API_EXPORT(int) ap_count_dirs(const char *path);
  1021. API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n);
  1022. API_EXPORT(char *) ap_make_dirstr_parent(pool *p, const char *s);
  1023. /* deprecated.  The previous two routines are preferred. */
  1024. API_EXPORT(char *) ap_make_dirstr(pool *a, const char *s, int n);
  1025. API_EXPORT(char *) ap_make_full_path(pool *a, const char *dir, const char *f);
  1026.  
  1027. API_EXPORT(int) ap_is_matchexp(const char *str);
  1028. API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp);
  1029. API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp);
  1030. API_EXPORT(char *) ap_stripprefix(const char *bigstring, const char *prefix);
  1031. API_EXPORT(char *) ap_strcasestr(const char *s1, const char *s2);
  1032. API_EXPORT(char *) ap_pbase64decode(pool *p, const char *bufcoded);
  1033. API_EXPORT(char *) ap_pbase64encode(pool *p, char *string); 
  1034. API_EXPORT(char *) ap_uudecode(pool *p, const char *bufcoded);
  1035. API_EXPORT(char *) ap_uuencode(pool *p, char *string); 
  1036.  
  1037. #ifdef OS2
  1038. void os2pathname(char *path);
  1039. char *ap_double_quotes(pool *p, char *str);
  1040. #endif
  1041.  
  1042. API_EXPORT(int)    ap_regexec(const regex_t *preg, const char *string,
  1043.                               size_t nmatch, regmatch_t pmatch[], int eflags);
  1044. API_EXPORT(size_t) ap_regerror(int errcode, const regex_t *preg, 
  1045.                                char *errbuf, size_t errbuf_size);
  1046. API_EXPORT(char *) ap_pregsub(pool *p, const char *input, const char *source,
  1047.                               size_t nmatch, regmatch_t pmatch[]);
  1048.  
  1049. API_EXPORT(void) ap_content_type_tolower(char *);
  1050. API_EXPORT(void) ap_str_tolower(char *);
  1051. API_EXPORT(int) ap_ind(const char *, char);    /* Sigh... */
  1052. API_EXPORT(int) ap_rind(const char *, char);
  1053.  
  1054. API_EXPORT(char *) ap_escape_quotes (pool *p, const char *instring);
  1055. API_EXPORT(void) ap_remove_spaces(char *dest, char *src);
  1056.  
  1057. /* Common structure for reading of config files / passwd files etc. */
  1058. typedef struct {
  1059.     int (*getch) (void *param);    /* a getc()-like function */
  1060.     void *(*getstr) (void *buf, size_t bufsiz, void *param); /* a fgets()-like function */
  1061.     int (*close) (void *param);    /* a close hander function */
  1062.     void *param;        /* the argument passed to getch/getstr/close */
  1063.     const char *name;        /* the filename / description */
  1064.     unsigned line_number;    /* current line number, starting at 1 */
  1065. } configfile_t;
  1066.  
  1067. /* Open a configfile_t as FILE, return open configfile_t struct pointer */
  1068. API_EXPORT(configfile_t *) ap_pcfg_openfile(pool *p, const char *name);
  1069.  
  1070. /* Allocate a configfile_t handle with user defined functions and params */
  1071. API_EXPORT(configfile_t *) ap_pcfg_open_custom(pool *p, const char *descr,
  1072.     void *param,
  1073.     int(*getc_func)(void*),
  1074.     void *(*gets_func) (void *buf, size_t bufsiz, void *param),
  1075.     int(*close_func)(void *param));
  1076.  
  1077. /* Read one line from open configfile_t, strip LF, increase line number */
  1078. API_EXPORT(int) ap_cfg_getline(char *buf, size_t bufsize, configfile_t *cfp);
  1079.  
  1080. /* Read one char from open configfile_t, increase line number upon LF */
  1081. API_EXPORT(int) ap_cfg_getc(configfile_t *cfp);
  1082.  
  1083. /* Detach from open configfile_t, calling the close handler */
  1084. API_EXPORT(int) ap_cfg_closefile(configfile_t *cfp);
  1085.  
  1086. #ifdef NEED_STRERROR
  1087. char *strerror(int err);
  1088. #endif
  1089.  
  1090. /* Misc system hackery */
  1091.  
  1092. API_EXPORT(uid_t) ap_uname2id(const char *name);
  1093. API_EXPORT(gid_t) ap_gname2id(const char *name);
  1094. API_EXPORT(int) ap_is_directory(const char *name);
  1095. API_EXPORT(int) ap_is_rdirectory(const char *name);
  1096. API_EXPORT(int) ap_can_exec(const struct stat *);
  1097. API_EXPORT(void) ap_chdir_file(const char *file);
  1098.  
  1099. #ifndef HAVE_CANONICAL_FILENAME
  1100. /*
  1101.  *  We can't define these in os.h because of dependence on pool pointer.
  1102.  */
  1103. #define ap_os_canonical_filename(p,f)  (f)
  1104. #define ap_os_case_canonical_filename(p,f)  (f)
  1105. #define ap_os_systemcase_filename(p,f)  (f)
  1106. #else
  1107. API_EXPORT(char *) ap_os_canonical_filename(pool *p, const char *file);
  1108. #ifdef WIN32
  1109. API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile);
  1110. API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile);
  1111. #elif defined(OS2)
  1112. API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile);
  1113. API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile);
  1114. #else
  1115. #define ap_os_case_canonical_filename(p,f) ap_os_canonical_filename(p,f)
  1116. #define ap_os_systemcase_filename(p,f) ap_os_canonical_filename(p,f)
  1117. #endif
  1118. #endif
  1119.  
  1120. #ifdef _OSD_POSIX
  1121. extern const char *os_set_account(pool *p, const char *account);
  1122. extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process);
  1123. #endif /* _OSD_POSIX */
  1124.  
  1125. char *ap_get_local_host(pool *);
  1126. unsigned long ap_get_virthost_addr(char *hostname, unsigned short *port);
  1127.  
  1128. extern API_VAR_EXPORT time_t ap_restart_time;
  1129.  
  1130. /*
  1131.  * Apache tries to keep all of its long term filehandles (such as log files,
  1132.  * and sockets) above this number.  This is to workaround problems in many
  1133.  * third party libraries that are compiled with a small FD_SETSIZE.  There
  1134.  * should be no reason to lower this, because it's only advisory.  If a file
  1135.  * can't be allocated above this number then it will remain in the "slack"
  1136.  * area.
  1137.  *
  1138.  * Only the low slack line is used by default.  If HIGH_SLACK_LINE is defined
  1139.  * then an attempt is also made to keep all non-FILE * files above the high
  1140.  * slack line.  This is to work around a Solaris C library limitation, where it
  1141.  * uses an unsigned char to store the file descriptor.
  1142.  */
  1143. #ifndef LOW_SLACK_LINE
  1144. #define LOW_SLACK_LINE    15
  1145. #endif
  1146. /* #define HIGH_SLACK_LINE      255 */
  1147.  
  1148. /*
  1149.  * The ap_slack() function takes a fd, and tries to move it above the indicated
  1150.  * line.  It returns an fd which may or may not have moved above the line, and
  1151.  * never fails.  If the high line was requested and it fails it will also try
  1152.  * the low line.
  1153.  */
  1154. #ifdef NO_SLACK
  1155. #define ap_slack(fd,line)   (fd)
  1156. #else
  1157. int ap_slack(int fd, int line);
  1158. #define AP_SLACK_LOW    1
  1159. #define AP_SLACK_HIGH    2
  1160. #endif
  1161.  
  1162. API_EXPORT(char *) ap_escape_quotes(pool *p, const char *instr);
  1163.  
  1164. /*
  1165.  * Redefine assert() to something more useful for an Apache...
  1166.  */
  1167. API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine)
  1168.                 __attribute__((noreturn));
  1169. #define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))
  1170.  
  1171. /* The optimized timeout code only works if we're not MULTITHREAD and we're
  1172.  * also not using a scoreboard file
  1173.  */
  1174. #if !defined (MULTITHREAD) && \
  1175.     (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD))
  1176. #define OPTIMIZE_TIMEOUTS
  1177. #endif
  1178.  
  1179. /* A set of flags which indicate places where the server should raise(SIGSTOP).
  1180.  * This is useful for debugging, because you can then attach to that process
  1181.  * with gdb and continue.  This is important in cases where one_process
  1182.  * debugging isn't possible.
  1183.  */
  1184. #define SIGSTOP_DETACH            1
  1185. #define SIGSTOP_MAKE_CHILD        2
  1186. #define SIGSTOP_SPAWN_CHILD        4
  1187. #define SIGSTOP_PIPED_LOG_SPAWN        8
  1188. #define SIGSTOP_CGI_CHILD        16
  1189.  
  1190. #ifdef DEBUG_SIGSTOP
  1191. extern int raise_sigstop_flags;
  1192. #define RAISE_SIGSTOP(x)    do { \
  1193.     if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\
  1194.     } while (0)
  1195. #else
  1196. #define RAISE_SIGSTOP(x)
  1197. #endif
  1198.  
  1199. API_EXPORT(extern const char *) ap_psignature(const char *prefix, request_rec *r);
  1200.  
  1201. /* strtoul does not exist on sunos4. */
  1202. #ifdef strtoul
  1203. #undef strtoul
  1204. #endif
  1205. #define strtoul strtoul_is_not_a_portable_function_use_strtol_instead
  1206.  
  1207. #ifdef __cplusplus
  1208. }
  1209. #endif
  1210.  
  1211. #endif    /* !APACHE_HTTPD_H */
  1212.